package day0421

func subarraySum(nums []int, k int) (cnt int) {
	mp := make(map[int]int)
	var sum int
	for _, value := range nums {
		sum += value
		if _, ok := mp[k-value]; ok {
			cnt += mp[k-value]
		}
		mp[sum]++
	}
	return cnt
}
